﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace DynamicDNS.Tests
{
    [TestClass]
    public class ConfigurationContextTests
    {
        [TestMethod]
        public void OpenFirstTimeTest()
        {
            var context = new ConfigurationContext();
            var config = context.Get();
            Assert.IsNotNull(config);
        }

        [TestMethod]
        public void SaveTest()
        {
            var context = new ConfigurationContext();
            var config = context.Get();
            config.StartType = Model.StartType.Disable;
            context.Save(config);
            config = context.Get();
            Assert.AreEqual(Model.StartType.Disable, config.StartType);
        }
        [TestMethod]
        public void SaveRecordTest()
        {
            var context = new ConfigurationContext();
            var config = context.Get();
            var record = new Model.Record() { Domain = "sathai.com", Host = "test", Password = "uchxttkl" };
            config.Records = new List<Model.Record>();
            config.Update(record);
            context.Save(config);
            config = context.Get();
            Assert.AreEqual(1, config.Records.Count);
        }
    }
}
